package cn.com.servlet;

import cn.com.bean.TraineeBean;
import cn.com.dao.impl.TraineeDaoImpl;
import cn.com.dao.info.TraineeDaoInfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "updateServlet")
public class UpdateServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name=request.getParameter("username");
        String id1= request.getParameter("id");
        int id=Integer.parseInt(id1);
        String sex=request.getParameter("sex");
        String age1=request.getParameter("age");
        int age=Integer.parseInt(age1);
        String school=request.getParameter("school");
        String sno=request.getParameter("sno");
        String phone=request.getParameter("phone");
        String email=request.getParameter("email");
        String status1=request.getParameter("status");
        int status=Integer.parseInt(status1);
        String begin_time=request.getParameter("begintime");
        String endtime=request.getParameter("endtime");
        String isdel1=request.getParameter("isdel");
        int isdel=Integer.parseInt(isdel1);

        //  private int id;
        //    private String name;
        //    private String sex;
        //    private int age;
        //    private String school;
        //    private String sno;
        //    private String phone;
        //    private String email;
        //    private String beginTime;
        //    private String endTime;
        //    private int isDel;
        //    private int status;
        TraineeBean bean=new TraineeBean(id,name,sex,age,school,sno,phone,email,begin_time ,endtime, isdel,status);
        TraineeDaoInfo dao=new TraineeDaoImpl() ;
        int a =dao.update(bean);

//        JSONObject json= JSONObject.fromObject(a);
//        response.setContentType("text/html");
//        PrintWriter pw=response.getWriter();
//        pw.print(json.toString());
//        pw.close();
        response.setContentType("text/html");
        PrintWriter pw=response.getWriter();
        pw.print("{\"result\":\"success\"}");
        pw.close();
    }


}
